package zjh.Servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.dbutils.handlers.MapListHandler;
import org.diyi.Servlet.BaseServlet;
import org.diyi.Tools.BaseDao;
import org.diyi.bean.ResponDate;




@WebServlet("/jifenServlet")
public class jefenServlet extends BaseServlet {
	ResponDate data= new ResponDate();

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setHeader("Content-Type", "text/html;charset=utf-8");
		this.request=request;
		this.response=response;
		Integer imgtype=getInt("imgtype");
	
		 Integer userid=getInt("userid");
		 
		 try {
			 if ("selectall".equals(getString("type"))) {
					System.out.println("selectall");
				List<Map<String, Object>> quaryList =BaseDao.query.query
						("select * from integral",new MapListHandler());
				
				response.getWriter().write(gson.toJson(quaryList));
			}
			 else if ("select".equals(getString("type"))) {
					System.out.println("select");
				List<Map<String, Object>> quaryList =BaseDao.query.query
						("select * from integral where userid=?",new MapListHandler() ,userid);
				
				response.getWriter().write(gson.toJson(quaryList));
			}
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
